package com.qcby.controller;

import com.qcby.common.MyExam.ResData;
import com.qcby.common.MyExam.ShowByPage;
import com.qcby.entity.Exam;
import com.qcby.entity.Result;
import com.qcby.service.MyTestService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jdk.nashorn.internal.ir.ReturnNode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/MyExam")
@Api(tags = "我的考试接口")
public class MyTestController {

    @Autowired
    MyTestService myTestService;

    @PostMapping("/ShowExamInfoByPage")
    @ApiOperation(value = "展示教师发布的考试与笔记自测")
    @ResponseBody
    public Result<List<ResData>> showExamInfoByPage(ShowByPage info){
        return myTestService.showExamInfoByPage(info);
    }

    @PostMapping("/GetExamCount")
    @ApiOperation(value = "获取所有可显示考试的数量")
    @ResponseBody
    public Result<Integer> getExamCount(ShowByPage info){
        return myTestService.getExamCount(info);
    }

    @PostMapping("/GetExamIdByInfo")
    @ApiOperation(value = "通过信息获取考试id")
    @ResponseBody
    public Result<Exam> getExamIdByInfo(@RequestBody Exam info){
        System.out.println("info = " + info);
        return myTestService.getExamIdByInfo(info);
    }

    @PostMapping("/getAllExamInfoByName")
    @ResponseBody
    public Result<List<ResData>> getAllExamInfoByName(String name){
        return myTestService.getAllExamInfoByName(name);
    }

}
